package com.cloud.mqtt.Emq;

import org.eclipse.paho.client.mqttv3.MqttConnectOptions;

/**
 * @program: mqtt
 * @description: mqtt连接信息
 * @author: Cloud
 * @create: 2020/11/21 10:00:42
 */
public class MQTTConnect {

    private String username = "cloud";

    private String password = "cloud666";

    // 初始化连接信息
    public MqttConnectOptions getOptions(){
        MqttConnectOptions options = new MqttConnectOptions();
        options.setCleanSession(true);
        options.setUserName(username);
        options.setPassword(password.toCharArray());
        options.setKeepAliveInterval(60);
        options.setConnectionTimeout(20);
        return options;
    }

    public MqttConnectOptions getOptions(MqttConnectOptions options) {
        options.setCleanSession(true);
        options.setUserName(username);
        options.setPassword(password.toCharArray());
        options.setConnectionTimeout(10);
        options.setKeepAliveInterval(20);
        return options;
    }

}
